import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:kepu/util/constant/constants.dart';
import 'package:kepu/widgets/textWithIcon.dart';

Widget customDetailWidget({
  required Size size,
  required BuildContext context,
  required String imageUrl,
  required String name,
  required String description,
  required String type,
  required String location,
}) {
  return SingleChildScrollView(
    child: Column(
      children: [
        Stack(
          children: [
            SizedBox(
              width: size.width,
              height: size.height * 0.35,
              child: CachedNetworkImage(
                imageUrl: imageUrlPrefix + imageUrl,
                fit: BoxFit.cover,
              ),
            ),
            Positioned(
              left: 12,
              top: 50,
              child: IconButton(
                onPressed: () {
                  Navigator.of(context).pop();
                },
                icon: Icon(
                  Icons.arrow_back_sharp,
                  color: Colors.white.withValues(alpha: 0.6),
                  size: 30,
                ),
              ),
            ),
          ],
        ),
        Transform.translate(
          offset: Offset(0, -30),
          child: Container(
            // margin: EdgeInsets.only(top: -20),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(30),
              color: Theme.of(context).scaffoldBackgroundColor,
            ),
            child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  //名称区
                  labelText(name, fontSize: 25),
                  SizedBox(height: 25),

                  //分布
                  labelText("分布"),
                  SizedBox(height: 5),
                  textWithIcon(
                    text: location,
                    color: Theme.of(
                      context,
                    ).primaryColor.withValues(alpha: 0.8),
                  ),
                  SizedBox(height: 15),
                  //类型
                  labelText("类型"),
                  SizedBox(height: 5),
                  Text(
                    "$name分布在$location地区，属于$type类型",
                    style: TextStyle(
                      fontSize: 15,
                      color: Theme.of(
                        context,
                      ).primaryColor.withValues(alpha: 0.8),
                    ),
                  ),
                  SizedBox(height: 15),

                  //描述
                  labelText("描述"),
                  SizedBox(height: 5),
                  Text(
                    description,
                    style: TextStyle(
                      color: Theme.of(
                        context,
                      ).primaryColor.withValues(alpha: 0.8),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ],
    ),
  );
}
